<template>
	<div class="a">
		<h1>我是A组件</h1>
		<h4>{{username}}</h4>
		<button @click="sendUsername">点我把用户名给其他组件</button>
	</div>
</template>

<script>
	export default {
		name:'A',
		data() {
			return {
				username:'张三'
			}
		},
		methods: {
			sendUsername(){
				this.$bus.$emit('get-username',this.username)
			}
		},
	}
</script>

<style scoped>
	.a{
		background-color: green;
		padding: 20px;
		width: 50%;
		height: 200px;
	}
</style>